package com.eascs.web.o2o.web.util;

import org.apache.commons.lang3.StringUtils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 * Created by user on 2017/2/21.
 */
public class BrowserUtils {

	public static String encodeFileName(String userAgent, String fileName) throws UnsupportedEncodingException {
		if(StringUtils.contains(userAgent, "MSIE")){            //IE浏览器
			fileName = URLEncoder.encode(fileName,"UTF8");
		}else if(StringUtils.contains(userAgent, "Mozilla")){    //Chrome,Firefox浏览器
			fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");
		}else{                                                    //其他浏览器
			fileName = URLEncoder.encode(fileName,"UTF8");
		}
		return fileName;
	}
}
